package com.wyd.command;

import com.wyd.command.cmd.*;
import com.wyd.command.receiver.Door;
import com.wyd.command.receiver.Light;
import com.wyd.command.receiver.Window;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Yudi Wang
 * @date 2022/1/27 16:44
 */
public class Main {
    public static void main(String[] args) {
        Invoker invoker = new Invoker(7);
        List<Command> commands = invoker.getCommands();
        commands.set(0, new DoorOpenCommand(new Door()));
        commands.set(1, new DoorCloseCommand(new Door()));
        commands.set(2,new LightOnCommand(new Light()));
        commands.set(3,new LightOffCommand(new Light()));
        commands.set(4, new WindowSwitchOnCommand(new Window()));
        commands.set(5, new WindowSwitchOffCommand(new Window()));

        List<Command> commandlist = new ArrayList<Command>();
        commandlist.add(new DoorCloseCommand(new Door()));
        commandlist.add(new LightOffCommand(new Light()));
        commandlist.add(new WindowSwitchOffCommand(new Window()));
        commands.set(6, new AllOffCommand(commandlist));

        System.out.println("--------------");
        invoker.pressButton(0);
        System.out.println("--------------");
        invoker.pressButton(1);
        System.out.println("--------------");
        invoker.pressButton(2);
        System.out.println("--------------");
        invoker.pressButton(3);
        System.out.println("--------------");
        invoker.pressButton(4);
        System.out.println("--------------");
        invoker.pressButton(5);
        System.out.println("--------------");
        invoker.pressUndoButton();
        System.out.println("--------------");
        invoker.pressButton(6);
    }
}
